package com.tf.integrated.controller;

import com.ccssoft.m8.common.ccssoft.modules.util.EntityWrapperHandle;
import com.ccssoft.m8.common.web.BaseController;
import com.tf.integrated.entity.DeviceinfoEntity;
import com.tf.integrated.service.DeviceinfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;


/**
 * 设置设备配置接口
 * @author allen
 * @date: 2020年9月14日上午10:56:20
 */
@Api(value = "设置设备配置接口",description="SetDeviceController")
@RestController
@RequestMapping("/setdevice")
public class SetDeviceController extends BaseController
{
    @Autowired
    private DeviceinfoService<DeviceinfoEntity> deviceinfoService;
    @ApiOperation("设置设备配置接口")
    @GetMapping("/")
    @CrossOrigin(origins = "*",maxAge = 86400)
    public String setdevice()
    {
        String format = "yyyy-MM-dd";
        SimpleDateFormat sdf = new  SimpleDateFormat(format);
        String curDate =  sdf.format(new Date());
        DeviceinfoEntity devinfoenty = new DeviceinfoEntity();
        long curtimelong =  System.currentTimeMillis();
        Random rdm = new Random(curtimelong);
        int rdval = 100+rdm.nextInt(900);
        devinfoenty.setDeviceid(rdval+""+curtimelong);
        devinfoenty.setDevicename("VSR"+curDate);
        devinfoenty.setDeviceurl("http://121.36.195.22:8088/v2");
        devinfoenty.setOeminfo("XX-VSR-AS1604AP-V100-00000011");//{"DeviceType":"XX-VSR-AS1604AP-V100","SN":"00000011"}
        devinfoenty.setOnline(1);
        deviceinfoService.insert(devinfoenty);
        return "setdevice  is  ok";
    }
}